#pragma once

#include <d3d11.h>
#include <d3dx11.h>


namespace Crows3D
{
   struct GraphicsSetupParameters
   {
      int  width;
      int  height;
      bool vsync;
      bool windowed;

      // TODO: Add AA
   };


   class Device
   {
   private:
      IDXGISwapChain*         swapChain;
      ID3D11Device*           device;
      ID3D11DeviceContext*    deviceContext;
      ID3D11RenderTargetView* renderTarget;

      // Rasterizer state
      ID3D11RasterizerState* rasterState;

      // Z Buffer
      ID3D11Texture2D* depthStencilBuffer;
	   ID3D11DepthStencilState* depthStencilState;
      ID3D11DepthStencilState* depthStencilDisabledState;
	   ID3D11DepthStencilView* depthStencilView;

      // Alpha blending
      ID3D11BlendState* alphaEnableBlendingState;
	   ID3D11BlendState* alphaDisableBlendingState;

   public:
      Device(void);
      ~Device(void);

      bool Initialize(HWND hwnd, GraphicsSetupParameters & parameters);

      void ClearBackbuffer(float color[4]);
      void ClearDepthStencil(float depth, unsigned int stencil);

      void Swap(void);

      ID3D11Device* GetDevice();

      ID3D11DeviceContext* GetDeviceContext();

      void EnableDepthBuffer(bool enable);

      void EnableAlphaBlending(bool enable);
   };
}